perm filename RANDOM.KNU[226,DBL] blob sn#002236 filedate 1973-03-09 generic text, type T, neo UTF8
title RANDOM
subttl Knuth algorithm for random number generation

t←1
t1←2
p←17

internal random
opdef outstr [ttyuuo 3,]

random:	skipe a
	jrst rangen
	call t,[sixbit /TIMER/]
	call t1,[sixbit /DATE/]
	rot t,12
	xor t,t1
	andcm t,[1B0+3]
	addi t,1
	movem t,a
	call t1,[sixbit /MSTIME/]
	xor t,t1
	movem t,x
rangen:	move t,x
	imul t,a
	add t,[=1824726041]
	andcm t,[1B0]
	movem t,x
	move t,-1(p)
	sub t,-2(p)
	addi t,1
	jumple t,[
		outstr [asciz /Bounds failure in RANDOM
/]
		calli 12]
	mul t,x
	add t,-2(p)
	sub p,[xwd 3,3]
	jrst @3(p)

x:	0
a:	0

end